﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ThienLoc
{
    public partial class UCTinTuc : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadTinTuc();
        }

        private void LoadTinTuc()
        {
            string sql = "SELECT TOP 7 * FROM tblTLTinTuc WHERE Flag = 1 ORDER BY CreateDate DESC";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            if (dt.Rows.Count > 0)
            {
                hplTenMon.NavigateUrl = "NoiDungTinTuc.aspx?mod=" + dt.Rows[0]["ID"];
                hplTenMon.Text = dt.Rows[0]["TenDM"].ToString();
                hplTenMon.Style.Add("text-transform", "uppercase");
                hplTitle.NavigateUrl = "NoiDungTinTuc.aspx?mod=" + dt.Rows[0]["ID"];
                imgImage.ImageUrl = dt.Rows[0]["Image"].ToString();
                lblContent.Text = dt.Rows[0]["TenDM"].ToString();
            }
            dt.Rows.RemoveAt(0);
            rptItem.DataSource = dt;
            rptItem.DataBind();
        }
    }
}